<?php

namespace app\data\controller\notarialoffice;

use app\data\model\Notary as NotaryModel;
use app\data\model\NotarialOffice as NotarialOfficeModel;
use think\admin\Controller;
use think\admin\helper\QueryHelper;

/**
 * 公证处管理
 * Class Balance
 * @package app\data\controller\notarialoffice
 */
class Notary extends Controller
{
    /**
     * 公证员列表
     * @auth true
     * @menu true
     */
    public function index()
    {
        NotaryModel::mQuery()->layTable(function () {
            $this->title = "公证员管理";
        }, function (QueryHelper $query) {
            $query->where(['deleted' => 0]);
            $query->like('name')->dateBetween('create_at');
            $query->append(['notarial_office_name']);
        });
    }

    /**
     * 添加公证员
     * @auth true
     */
    public function add()
    {
        NotaryModel::mForm('form');
    }

    /**
     * 编辑公证员
     * @auth true
     */
    public function edit()
    {
        NotaryModel::mForm('form');
    }

    /**
     * 删除公证员
     * @auth true
     */
    public function remove()
    {
        NotaryModel::mDelete();
    }

    /**
     * 添加拼团商品表单处理
     * @param array $data
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    protected function _form_filter(&$data)
    {
        if ($this->request->isGet()) {
            $this->cates = NotarialOfficeModel::field('id,name')->select()->toArray();
        } else {

        }
    }
}